package com.visionblue.business.ship.util;

/**
 * @author: xlh
 * @date: 2020-06-19 2:18 PM
 * @desc:
 */
public class GBKHexUtil {

    public static String string2HexGBK(String strPart) {
        return string2HexString(strPart,"GBK");
    }

    public static String string2HexString(String strPart,String tochartype) {
        try{
            return bytes2HexString(strPart.getBytes(tochartype));
        }catch (Exception e){
            return "";
        }
    }

    public static String bytes2HexString(byte[] b) {
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            result.append(String.format("%02X",b[i]));
            result.append(" ");
        }
        return result.toString();
    }
}
